<%@ page contentType="text/html;charset=UTF-8" %>
<%@ include file="/WEB-INF/views/include/taglib.jsp" %>
<html>
<head>
    <title>查询书籍</title>
    <meta name="decorator" content="default"/>
    <script>
        $(function(){
            $("tr").mouseover(function(){
                $(this).children().css("background-color", " #00eeee");
            }).mouseout(function(){
                $(this).children().css("background-color", " #ffffff");
            });
        });
        function getBookId(){
            return $("input:radio[name='bkId']:checked").val();
        }
        function selectBookId(bkId){
            $("#radio_"+bkId).attr("checked","checked");
            window.parent.bkId = bkId;
            window.parent.window.jBox.close();
        }
    </script>
    <style>
        tr{
            cursor: pointer;
        }
    </style>
</head>
<body>
<table id="contentTable" class="table table-striped table-bordered table-condensed">
    <thead>
    <tr>
        <th>序号</th>
        <th>ISBN</th>
        <th>题名</th>
        <th>分类</th>
        <th>著者</th>
        <th>丛编</th>
        <th>分册号</th>
        <th>出版社</th>
        <th>出版日期</th>
        <th>操作</th>
    </tr>
    </thead>
    <tbody>
    <c:forEach items="${bookInfos}" var="info" varStatus="status">
        <tr ondblclick="selectBookId('${info.id}')">
            <td><input id="radio_${info.id}" type="radio" name="bkId" value="${info.id}"/></td>
            <td>${info.isbn}</td>
            <td>${info.bookname}<c:if test="${not empty info.othername}">-${info.othername}</c:if></td>
            <td>${info.classcode}</td>
            <td>${info.author}</td>
            <td>${info.books}</td>
            <td>${info.booksNum}</td>
            <td>${info.publisher}</td>
            <td>${info.pubdate}</td>
            <td>
                <shiro:hasPermission name="book:store:delete">
                    <a href="javascript:deleteBookInfo('${info.id}')">删除</a>
                </shiro:hasPermission>
            </td>
        </tr>
    </c:forEach>
    </tbody>
</table>
<script type="text/javascript">
    function deleteBookInfo(bkId){
        $.ajax({
            type: "POST",
            url: "${ctx}/book/manage/delete",
            data: {bkId: bkId},
            dataType: "json",
            success: function (data) {
                if (data.code == "0001") {
                    top.$.jBox.info(data.msg, '提示', {
                        closed: function () {
                            location.reload();
                        }
                    });
                    top.$('.jbox-body .jbox-icon').css('top', '55px');

                } else {
                    alertx("删除书籍信息失败");
                }
            }
        });
    }
</script>
</body>
</html>